import storageUtil from '@/utils/StorageUtil'

// local storage Key常量
export const ConditionShowListCkedKey = 'TLogErp-condition-column-show-cked-list-key'
export const ColumnShowListCkedKey = 'TLogErp-list-column-show-cked-list-key'
export const isDropMenuKey = 'TLogErp-list-column-show-isdropmenu-key'
export const ColumnShowListWidthKey = 'TLogErp-list-column-width-key'

// 查询条件 type: input/date/date-range/int-range/select/tree/
export const conditionOptions = [
  { property: 'id', label: 'ID', width: 200, default: true, type: 'input' },
  { property: 'batchNo', label: 'batch_no', width: 200, default: true, type: 'input' },
  { property: 'totalNum', label: 'total_num', width: 200, default: true, type: 'input' },
  { property: 'currentNum', label: 'current_num', width: 200, default: true, type: 'input' },
  { property: 'merchantCode', label: 'merchant_code', width: 200, default: true, type: 'input' },
  { property: 'carioId', label: 'cario_id', width: 200, default: true, type: 'input' },
  { property: 'tInfoGoodsId', label: 't_info_goods_id', width: 200, default: true, type: 'input' },
  { property: 'tInfoSupplierId', label: 't_info_supplier_id', width: 200, default: true, type: 'input' },
  { property: 'orgCode', label: 'org_code', width: 200, default: true, type: 'input' },
  { property: 'deleteflag', label: '删除标志', width: 200, default: true, type: 'select' },
  { property: 'createdate', label: '创建日期', width: 200, default: true, type: 'date-range' },
  { property: 'createman', label: '创建人', width: 200, default: true, type: 'input' },
  { property: 'createmanId', label: '创建人ID', width: 200, default: true, type: 'input' },
  { property: 'owOffpostEventType', label: 'ow_offpost_event_type', width: 200, default: true, type: 'input' }
]

// 所有列对象
export const theadOptions = [
  { property: 'id', label: 'ID', width: storageUtil.getColumnWidthFromStorage('id', 200, ColumnShowListWidthKey), default: true, edit: false, sort: 'custom' },
  { property: 'batchNo', label: 'batch_no', width: storageUtil.getColumnWidthFromStorage('batchNo', 200, ColumnShowListWidthKey), default: true, edit: true, sort: false },
  { property: 'totalNum', label: 'total_num', width: storageUtil.getColumnWidthFromStorage('totalNum', 200, ColumnShowListWidthKey), default: true, edit: true, sort: false },
  { property: 'currentNum', label: 'current_num', width: storageUtil.getColumnWidthFromStorage('currentNum', 200, ColumnShowListWidthKey), default: true, edit: true, sort: false },
  { property: 'merchantCode', label: 'merchant_code', width: storageUtil.getColumnWidthFromStorage('merchantCode', 200, ColumnShowListWidthKey), default: true, edit: true, sort: false },
  { property: 'carioId', label: 'cario_id', width: storageUtil.getColumnWidthFromStorage('carioId', 200, ColumnShowListWidthKey), default: true, edit: true, sort: false },
  { property: 'tInfoGoodsId', label: 't_info_goods_id', width: storageUtil.getColumnWidthFromStorage('tInfoGoodsId', 200, ColumnShowListWidthKey), default: true, edit: true, sort: false },
  { property: 'tInfoSupplierId', label: 't_info_supplier_id', width: storageUtil.getColumnWidthFromStorage('tInfoSupplierId', 200, ColumnShowListWidthKey), default: true, edit: true, sort: false },
  { property: 'orgCode', label: 'org_code', width: storageUtil.getColumnWidthFromStorage('orgCode', 200, ColumnShowListWidthKey), default: true, edit: true, sort: false },
  { property: 'deleteflag', label: '删除标志', width: storageUtil.getColumnWidthFromStorage('deleteflag', 200, ColumnShowListWidthKey), default: true, edit: true, sort: false },
  { property: 'createdate', label: '创建日期', width: storageUtil.getColumnWidthFromStorage('createdate', 200, ColumnShowListWidthKey), default: true, edit: false, sort: false },
  { property: 'createman', label: '创建人', width: storageUtil.getColumnWidthFromStorage('createman', 200, ColumnShowListWidthKey), default: true, edit: false, sort: false },
  { property: 'modifydate', label: '修改日期', width: storageUtil.getColumnWidthFromStorage('modifydate', 200, ColumnShowListWidthKey), default: true, edit: false, sort: false },
  { property: 'modifyman', label: '修改人', width: storageUtil.getColumnWidthFromStorage('modifyman', 200, ColumnShowListWidthKey), default: true, edit: false, sort: false },
  { property: 'owOffpostEventType', label: 'ow_offpost_event_type', width: storageUtil.getColumnWidthFromStorage('owOffpostEventType', 200, ColumnShowListWidthKey), default: true, edit: true, sort: false }
]

export const pickerOptions = {
  shortcuts: [{
    text: '最近一周',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近一个月',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近三个月',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
      picker.$emit('pick', [start, end])
    }
  }]
}

export const pickerOptionsSingleDate = {
  disabledDate(time) {
    return time.getTime() > Date.now()
  },
  shortcuts: [{
    text: '今天',
    onClick(picker) {
      picker.$emit('pick', new Date())
    }
  }, {
    text: '昨天',
    onClick(picker) {
      const date = new Date()
      date.setTime(date.getTime() - 3600 * 1000 * 24)
      picker.$emit('pick', date)
    }
  }, {
    text: '一周前',
    onClick(picker) {
      const date = new Date()
      date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
      picker.$emit('pick', date)
    }
  }]
}
